HAL HASH migration: List of applicable concepts

This section provides information about the HAL HASH applicable architecture concepts.

Concepts for HASH

Concept

Description

Separation of initialization and configuration functions

The initialization has been split into separate initialization and configuration functions:

  • HAL_HASH_Init: Initializes the handle and links it to a HASH instance.

  • Provide separate configurations for HASH and HMAC processing modes, each with its own dedicated parameters.

Removal and conversion of init structure to configuration structure

The initialization structure has been removed from the handle and converted into set configuration for each HASH or HMAC process.

Renaming of the handle structure

The handle structure has been renamed to hal_hash_handle_t.

Renaming unitary init structures

The HASH_InitTypeDef structure is no longer available and has been replaced by hal_hash_config_t for HASH processing mode and hal_hash_hmac_config_t for HMAC processing mode.

Remove MspInit and MspDeInit callbacks

HAL_HASH_MspInit and HAL_HASH_MspDeInit are no longer available and have been replaced by a user sequence to initialize and configure theHASH.

Unitary configuration APIs

New APIs are available to get and set HASH features.

Dedicated DMA link APIs replace generic __HAL_LINKDMA macro

The __HAL_LINKDMA macro has been removed, and new functions are provided to link a HAL HASH handle to a HAL DMA handle..

Introduction of HAL user data set/get APIs

Two functions to set/get user data are available: HAL_HASH_SetUserData``and ``HAL_HASH_GetUserData.

Individual callback registration APIs replace global register and unregister functions

The callback registration is handled by specific functions for each HASH event. These functions are used to register callback functions for different HASH events.

Removal of hardware-related macros in HAL2

All hardware macros have been removed from the HAL HASH driver, and equivalent services are ensured through the LL APIs.

Revised and optimized HAL state machine

The HASH state machine is reworked to ensure transitions of the peripheral functional states.

  • state reset: HASH is not initialized

  • state init: no valid configuration is applied

  • state idle: valid configuration is applied

  • state active: HASH processing is ongoing

  • state suspend: suspend operation is executed

  • state abort: an abort operation is executed

Revised and optimized HAL API status returns

The HAL HASH functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

Revised and optimized HAL error management

Redesign the error handling mechanisms within the HAL to enhance the detection, reporting, and management of errors.

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL HASH driver have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Merge HAL extension files with common ones and remove the EX prefix from APIs.

Only one HAL HASH header file remains and all macros, define statements, and functions from hal_hash_ex.h have been moved to hal_hash.h.

Assertion implementation and usage in HAL1

Parameters and states are checked using ASSERT_DBG_STATE and ASSERT_DBG_PARAM macro.

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including HASH instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL HASH functions start with HAL_HASH. All HAL HASH enumerations and structures start with HAL_HASH